package com.xzzz.common.base.util.security;

import java.security.SecureRandom;

/**
 * 获取随机盐值
 *
 * @author wangyf
 *
 */
public class SaltUtil {

    /**
     * 安全随机类
     */
    private static final SecureRandom RANDOM = new SecureRandom();

    /**
     * 获取随机盐值
     * @return 加盐
     */
    public static String randomSalt() {
        byte[] bytes = new byte[15];
        RANDOM.nextBytes(bytes);
        return org.apache.commons.codec.binary.Base64.encodeBase64String(bytes);
    }

    public static void main(String[] args) {
        System.out.println(randomSalt());
    }
}
